#ifndef EVENT_H_SELECT_93FJLDSF34RJ
#define EVENT_H_SELECT_93FJLDSF34RJ

#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif

//#define EV_TIMEOUT  0x01
#define EV_READ     0x02
#define EV_WRITE    0x04
//#define EV_SIGNAL   0x08
#define EV_PERSIST  0x10    /* Persistant event */

#define EVENT_INIT	0x80

struct event_base; 

struct event
{
    struct event_base *base;
    int fd;
    short events;

    void (*callback)(int, short, void* ctx);
    void* ctx;

    union 
    {
        void* ptr;
        int idx;
    }pos;
    int flags;
};



void *event_init(void);
int event_dispatch(void);
int event_base_dispatch(struct event_base *);
void event_base_free(struct event_base *);

void event_set(struct event *, int, short, void (*)(int, short, void *), void *);
int event_base_set(struct event_base *, struct event *);

int event_add(struct event *, struct timeval *);
int event_del(struct event *);


#ifdef __cplusplus
}
#endif

#endif /* EVENT_H_SELECT_93FJLDSF34RJ */
